package com.wang.back.controller;

import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wang.common.pojo.BasePojoEnum;
import com.wang.common.pojo.BaseQuery;
import com.wang.common.util.ConstatFinalUtil;
import com.wang.common.web.controller.BaseController;
import com.wang.users.pojo.AtRbacAdmins;
import com.wang.users.pojo.AtUsersActivity;
import com.wang.users.pojo.AtUsersActivityEnum;
import com.wang.users.pojo.AtUsersActivityQuery;
import com.wang.users.pojo.AtUsersDesc;
import com.wang.users.pojo.AtUsersDescQuery;
import com.wang.users.pojo.AtUsersInvestigate;
import com.wang.users.pojo.AtUsersInvestigateEnum;
import com.wang.users.pojo.AtUsersInvestigateQuery;
import com.wang.users.pojo.AtUsersOrgan;
import com.wang.users.pojo.AtUsersOrganQuery;
import com.wang.users.pojo.AtUsersReport;
import com.wang.users.pojo.AtUsersReportQuery;
import com.wang.users.pojo.AtUsersSchedule;
import com.wang.users.pojo.AtUsersScheduleEnum;
import com.wang.users.pojo.AtUsersScheduleQuery;
import com.wang.users.service.AtUsersActivityService;
import com.wang.users.service.AtUsersDescService;
import com.wang.users.service.AtUsersInvestigateService;
import com.wang.users.service.AtUsersOperService;
import com.wang.users.service.AtUsersOrganService;
import com.wang.users.service.AtUsersReportService;
import com.wang.users.service.AtUsersScheduleService;
import jakarta.servlet.http.HttpSession;
import lombok.extern.log4j.Log4j2;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
 * 示例的Controller
 * @author ZjxMi
 */
@Controller
@RequestMapping("/back/users")
@Log4j2
public class UsersBackController extends BaseController {
    @Autowired
    private AtUsersOrganService usersOrganService;
    @Autowired
    private AtUsersOperService usersOperService;
    @Autowired
    private AtUsersDescService usersDescService;
    @Autowired
    private AtUsersScheduleService usersScheduleService;
    @Autowired
    private AtUsersInvestigateService usersInvestigateService;
    @Autowired
    private AtUsersReportService usersReportService;
    @Autowired
    private AtUsersActivityService usersActivityService;

    /**
     * 组织查询多条
     * @return
     */
    @RequestMapping("/organList")
    public String organList(AtUsersOrganQuery paramQuery, Model model){
        log.info("==组织列表==");
        /* 分页对象 */
        IPage<AtUsersOrgan> paramPage = null;
        try {
            paramPage = new Page<>(paramQuery.getCurrent(), paramQuery.getSize());
        } catch (Exception e) {
            paramPage = new Page<>(1, 20);
        }
        /* 时间处理 */
        if (StringUtils.isNotEmpty(paramQuery.getStDate())) {
            paramQuery.setPubTimeSt(this.dateUtil.strToDateTime(paramQuery.getStDate()));
        }
        if (StringUtils.isNotEmpty(paramQuery.getEdDate())) {
            paramQuery.setPubTimeEd(this.dateUtil.strToDateTime(paramQuery.getEdDate()));
        }
        paramQuery.addLike();
        /* 查询对象 */
        List<AtUsersOrgan> dataList = this.usersOrganService.findList(paramPage, paramQuery);
        paramQuery.removeLike();
        /* 列表数据 */
        model.addAttribute(ConstatFinalUtil.FINAL_CODE_DATALIST, dataList);
        /* 分页数据 */
        model.addAttribute(ConstatFinalUtil.FINAL_CODE_PAGEINFOUTIL, paramPage);
        model.addAttribute(ConstatFinalUtil.FINAL_CODE_PARAMQUERY, paramQuery);
        model.addAttribute(ConstatFinalUtil.FINAL_CODE_ENUMSONE, new AtUsersOrgan());
        /* 查询数据 */
        return "back/users/organList";
    }

    /**
     * 组织查询多条(树形)
     * @return
     */
    @RequestMapping("/organTreeList")
    public String organTreeList(AtUsersOrganQuery paramQuery, Model model){
        log.info("==组织列表(树形)==");
        AtUsersOrgan entity = paramQuery.getEntity();
        entity.setStatus(BasePojoEnum.STATUS_ENABLE.getCode());
        entity.setDelFlag(BasePojoEnum.DELFLAG_NO.getCode());
        /* 查询对象 */
        List<AtUsersOrgan> dataList = this.usersOrganService.findList(null, paramQuery);
        paramQuery.removeLike();
        JSONArray treeArr = this.usersOperService.treeJson(dataList);
        /* 列表数据 */
        model.addAttribute(ConstatFinalUtil.FINAL_CODE_DATALIST, treeArr.toJSONString());
        /* 查询数据 */
        return "back/users/organTreeList";
    }

    /**
     * 组织打开添加页面
     * @return
     */
    @RequestMapping("/organInsert")
    public String organInsert(AtUsersOrganQuery paramQuery, Model model){
        log.info("==组织添加==");
        model.addAttribute(ConstatFinalUtil.FINAL_CODE_ONE, paramQuery.getEntity());
        /* 查询数据 */
        return "back/users/organInsert";
    }

    /**
     * 组织添加提交操作
     * @return
     */
    @RequestMapping("/organInsertSubmit")
    @ResponseBody
    public String organInsertSubmit(AtUsersOrganQuery paramQuery, Model model){
        log.info("==组织添加提交==");
        boolean dbFlag = this.usersOrganService.save(paramQuery.getEntity());
        JSONObject resultJson = this.proccedResponseJson(dbFlag);
        /* 返回json给客户端 */
        return resultJson.toJSONString();
    }

    /**
     * 组织打开更新页面
     * 更新和详情是同一个页面;
     * @return
     */
    @RequestMapping("/organUpdate")
    public String organUpdate(AtUsersOrganQuery paramQuery, Model model){
        log.info("==组织更新==");
        /* 根据id查询 */
        AtUsersOrgan one = this.usersOrganService.findOne(paramQuery);
        one = this.usersOrganService.findTreeList(one.getId());
        model.addAttribute(ConstatFinalUtil.FINAL_CODE_ONE, one);

        if (BaseQuery.FINAL_OPER_UPDATE.equalsIgnoreCase(paramQuery.getOperType())) {
            /* 查询数据 */
            return "back/users/organUpdate";
        }
        /* 查询数据 */
        return "back/users/organInfo";
    }

    /**
     * 组织更新提交操作
     * <pre>
     * 组织表有10个字段,用户填写的只有5个字段;
     * 更新的时候只更新5个字段;剩下的5个字段不用更新
     * 千万不要把页面中传的参数SpringMVC会自动创建对象,这个对象不要直接更新数据库,很危险;
     * </pre>
     * @return
     */
    @RequestMapping("/organUpdateSubmit")
    @ResponseBody
    public String organUpdateSubmit(AtUsersOrganQuery paramQuery, Model model){
        log.info("==组织更新提交==");
        AtUsersOrgan entity = paramQuery.getEntity();
        if (StringUtils.isNotEmpty(paramQuery.getPubTime())) {
            entity.setPubTime(this.dateUtil.strToDateTime(paramQuery.getPubTime()));
        }
        boolean dbFlag = this.usersOrganService.updateById(entity);
        JSONObject resultJson = this.proccedResponseJson(dbFlag);
        /* 返回json给客户端 */
        return resultJson.toJSONString();
    }

    /**
     * 组织打开添加页面
     * @return
     */
    @RequestMapping("/organBatch")
    @ResponseBody
    public String organBatch(AtUsersOrganQuery paramQuery, Model model) {
        log.info("==组织批量提交==");
        String operType = paramQuery.getOperType();
        String[] ids = paramQuery.getIds();
        String info = ConstatFinalUtil.FINAL_OPER_SUCCESS;
        int totalCount = 0;
        int succedCount = 0;
        int failedCount = 0;
        if (StringUtils.isNotEmpty(operType)) {
            if (Objects.nonNull(ids) && ids.length > 0) {
                totalCount = ids.length;
                for (String idTemp : ids) {
                    try {
                        AtUsersOrganQuery paramQueryTemp = new AtUsersOrganQuery();
                        AtUsersOrgan entity = paramQueryTemp.getEntity();
                        entity.setId(idTemp);
                        /* 根据id查询每一个 记录对象 */
                        AtUsersOrgan dataDbResult = this.usersOrganService.findOne(paramQueryTemp);
                        if (dataDbResult != null) {
                            boolean dbFlag = false;
                            if (BasePojoEnum.OPERTYPE_DELETE.getCode().equalsIgnoreCase(operType)) {
                                /* 删除 */
                                dbFlag = this.usersOrganService.removeById(idTemp);
                            } else if (BasePojoEnum.OPERTYPE_RESTORE.getCode().equalsIgnoreCase(operType)) {
                                /* 还原,为什么这里面要传这么多参数,一切的一切就是为了在xml中拼装sql语句 */
                                paramQueryTemp = new AtUsersOrganQuery();
                                entity = paramQueryTemp.getEntity();
                                entity.setDelFlag(BasePojoEnum.DELFLAG_NO.getCode());
                                entity.setId(idTemp);
                                paramQueryTemp.setOperType(BasePojoEnum.OPERTYPE_RESTORE.getCode());
                                dbFlag = this.usersOrganService.updateBatch(paramQueryTemp) > 0;
                            } else if (BasePojoEnum.OPERTYPE_EMPTY.getCode().equalsIgnoreCase(operType)) {
                                /* 清空 */
                                paramQueryTemp = new AtUsersOrganQuery();
                                entity = paramQueryTemp.getEntity();
                                entity.setId(idTemp);
                                dbFlag = this.usersOrganService.deleteBatch(paramQueryTemp) > 0;
                            } else if (BasePojoEnum.OPERTYPE_UPDATESTATUS.getCode().equalsIgnoreCase(operType)) {
                                /* 批量修改状态 */
                                dataDbResult.setStatus(paramQuery.getEntity().getStatus());
                                dbFlag = this.usersOrganService.updateById(dataDbResult);
                            }
                            if (dbFlag) {
                                succedCount++;
                            } else {
                                failedCount++;
                            }
                        }
                    } catch (Exception e) {
                        log.error("批量操作失败了,id:{}", idTemp, e);
                        failedCount++;
                    }
                }
            } else {
                /* 未选择类型,ids */
                info = "ids为空";
            }
        } else {
            /* 操作类型未选择 */
            info = "操作类型未选择";
        }

        String messInfo = "批量操作日志:提示信息:${info}, 总条数:${totalCount},成功条数:${succedCount},失败条数:${failedCount}";
        Map<String, String> paramsMap = new HashMap<>(1);
        paramsMap.put("info", info);
        paramsMap.put("totalCount", String.valueOf(totalCount));
        paramsMap.put("succedCount", String.valueOf(succedCount));
        paramsMap.put("failedCount", String.valueOf(failedCount));
        messInfo = this.regexUtil.replaceOperator(messInfo, paramsMap);

        paramsMap = new HashMap<>(1);
        paramsMap.put(ConstatFinalUtil.FINAL_CONFIG_INFO_SUCCESS_PARAM1, messInfo);
        /* 查询数据 */
        JSONObject resultJson = this.proccedResponseJson(ConstatFinalUtil.FINAL_OPER_SUCCESS.equalsIgnoreCase(info), paramsMap);
        log.info("==结果:{}==", resultJson);
        return resultJson.toJSONString();
    }

    /**
     * 员工查询多条
     * @return
     */
    @RequestMapping("/usersDescList")
    public String usersDescList(AtUsersDescQuery paramQuery, Model model){
        log.info("==员工列表==");
        /* 分页对象 */
        IPage<AtUsersDesc> paramPage = null;
        try {
            paramPage = new Page<>(paramQuery.getCurrent(), paramQuery.getSize());
        } catch (Exception e) {
            paramPage = new Page<>(1, 20);
        }
        /* 时间处理 */
        if (StringUtils.isNotEmpty(paramQuery.getStDate())) {
            paramQuery.setPubTimeSt(this.dateUtil.strToDateTime(paramQuery.getStDate()));
        }
        if (StringUtils.isNotEmpty(paramQuery.getEdDate())) {
            paramQuery.setPubTimeEd(this.dateUtil.strToDateTime(paramQuery.getEdDate()));
        }
        paramQuery.addLike();
        /* 查询对象 */
        List<AtUsersDesc> dataList = this.usersDescService.findList(paramPage, paramQuery);
        paramQuery.removeLike();
        /* 列表数据 */
        model.addAttribute(ConstatFinalUtil.FINAL_CODE_DATALIST, dataList);
        /* 分页数据 */
        model.addAttribute(ConstatFinalUtil.FINAL_CODE_PAGEINFOUTIL, paramPage);
        model.addAttribute(ConstatFinalUtil.FINAL_CODE_PARAMQUERY, paramQuery);
        model.addAttribute(ConstatFinalUtil.FINAL_CODE_ENUMSONE, new AtUsersDesc());
        /* 查询数据 */
        return "back/users/usersDescList";
    }

    /**
     * 员工打开添加页面
     * @return
     */
    @RequestMapping("/usersDescInsert")
    public String usersDescInsert(AtUsersDescQuery paramQuery, Model model){
        log.info("==员工添加==");
        AtUsersOrganQuery paramQueryCond = new AtUsersOrganQuery();
        this.organTreeList(paramQueryCond, model);
        model.addAttribute(ConstatFinalUtil.FINAL_CODE_ONE, paramQuery.getEntity());
        /* 查询数据 */
        return "back/users/usersDescInsert";
    }

    /**
     * 员工添加提交操作
     * @return
     */
    @RequestMapping("/usersDescInsertSubmit")
    @ResponseBody
    public String usersDescInsertSubmit(AtUsersDescQuery paramQuery, Model model){
        log.info("==员工添加提交==");
        boolean dbFlag = this.usersDescService.save(paramQuery.getEntity());
        JSONObject resultJson = this.proccedResponseJson(dbFlag);
        /* 返回json给客户端 */
        return resultJson.toJSONString();
    }

    /**
     * 员工打开更新页面
     * 更新和详情是同一个页面;
     * @return
     */
    @RequestMapping("/usersDescUpdate")
    public String usersDescUpdate(AtUsersDescQuery paramQuery, Model model){
        log.info("==员工更新==");
        /* 根据id查询 */
        AtUsersDesc one = this.usersDescService.findOne(paramQuery);
        model.addAttribute(ConstatFinalUtil.FINAL_CODE_ONE, one);
        model.addAttribute(BaseQuery.OPERTYPE_FINA, paramQuery.getOperType());

        if (BaseQuery.FINAL_OPER_UPDATE.equalsIgnoreCase(paramQuery.getOperType())) {
            AtUsersOrganQuery paramQueryCond = new AtUsersOrganQuery();
            this.organTreeList(paramQueryCond, model);
            /* 查询数据 */
            return "back/users/usersDescUpdate";
        }else if (BaseQuery.FINAL_OPER_UPDATE_RESETPASS.equalsIgnoreCase(paramQuery.getOperType())) {
            /* 查询数据 */
            return "back/users/usersResetPass";
        }
        /* 查询数据 */
        return "back/users/usersDescInfo";
    }

    /**
     * 员工更新提交操作
     * <pre>
     * 员工表有10个字段,用户填写的只有5个字段;
     * 更新的时候只更新5个字段;剩下的5个字段不用更新
     * 千万不要把页面中传的参数SpringMVC会自动创建对象,这个对象不要直接更新数据库,很危险;
     * </pre>
     * @return
     */
    @RequestMapping("/usersDescUpdateSubmit")
    @ResponseBody
    public String usersDescUpdateSubmit(AtUsersDescQuery paramQuery, Model model){
        log.info("==员工更新提交==");
        AtUsersDesc entity = paramQuery.getEntity();

        boolean updateFlag = false;
        if (BaseQuery.FINAL_OPER_UPDATE.equalsIgnoreCase(paramQuery.getOperType())) {
            if (StringUtils.isNotEmpty(paramQuery.getPubTime())) {
                entity.setPubTime(this.dateUtil.strToDateTime(paramQuery.getPubTime()));
            }
            if (StringUtils.isNotEmpty(paramQuery.getEmpTime())) {
                entity.setEmpTime(this.dateUtil.strToDate(paramQuery.getEmpTime()));
            }
            if (StringUtils.isNotEmpty(paramQuery.getJoinJobTime())) {
                entity.setJoinJobTime(this.dateUtil.strToDate(paramQuery.getJoinJobTime()));
            }

            updateFlag = true;
        }else if (BaseQuery.FINAL_OPER_UPDATE_RESETPASS.equalsIgnoreCase(paramQuery.getOperType())) {
            String encryptPass = this.encryptUtil.encrypt(entity.getPassword());
            entity.setPassword(encryptPass);
            updateFlag = true;
        }
        boolean dbFlag = false;
        if (updateFlag) {
            dbFlag = this.usersDescService.updateById(entity);
        }
        JSONObject resultJson = this.proccedResponseJson(dbFlag);
        /* 返回json给客户端 */
        return resultJson.toJSONString();
    }

    /**
     * 员工打开添加页面
     * @return
     */
    @RequestMapping("/usersDescBatch")
    @ResponseBody
    public String usersDescBatch(AtUsersDescQuery paramQuery, Model model){
        log.info("==员工批量提交==");
        String operType = paramQuery.getOperType();
        String[] ids = paramQuery.getIds();
        String info = ConstatFinalUtil.FINAL_OPER_SUCCESS;
        int totalCount = 0;
        int succedCount = 0;
        int failedCount = 0;
        if (StringUtils.isNotEmpty(operType)) {
            if (Objects.nonNull(ids) && ids.length > 0) {
                totalCount = ids.length;
                for (String idTemp : ids) {
                    try {
                        AtUsersDescQuery paramQueryTemp = new AtUsersDescQuery();
                        AtUsersDesc entity = paramQueryTemp.getEntity();
                        entity.setId(idTemp);
                        /* 根据id查询每一个 记录对象 */
                        AtUsersDesc dataDbResult = this.usersDescService.findOne(paramQueryTemp);
                        if (dataDbResult != null) {
                            boolean dbFlag = false;
                            if (BasePojoEnum.OPERTYPE_DELETE.getCode().equalsIgnoreCase(operType)) {
                                /* 删除 */
                                dbFlag = this.usersDescService.removeById(idTemp);
                            } else if (BasePojoEnum.OPERTYPE_RESTORE.getCode().equalsIgnoreCase(operType)) {
                                /* 还原,为什么这里面要传这么多参数,一切的一切就是为了在xml中拼装sql语句 */
                                paramQueryTemp = new AtUsersDescQuery();
                                entity = paramQueryTemp.getEntity();
                                entity.setDelFlag(BasePojoEnum.DELFLAG_NO.getCode());
                                entity.setId(idTemp);
                                paramQueryTemp.setOperType(BasePojoEnum.OPERTYPE_RESTORE.getCode());
                                dbFlag = this.usersDescService.updateBatch(paramQueryTemp) > 0 ;
                            } else if (BasePojoEnum.OPERTYPE_EMPTY.getCode().equalsIgnoreCase(operType)) {
                                /* 清空 */
                                paramQueryTemp = new AtUsersDescQuery();
                                entity = paramQueryTemp.getEntity();
                                entity.setId(idTemp);
                                dbFlag = this.usersDescService.deleteBatch(paramQueryTemp) > 0 ;
                            } else if (BasePojoEnum.OPERTYPE_UPDATESTATUS.getCode().equalsIgnoreCase(operType)) {
                                /* 批量修改状态 */
                                dataDbResult.setStatus(paramQuery.getEntity().getStatus());
                                dbFlag = this.usersDescService.updateById(dataDbResult);
                            }
                            if (dbFlag) {
                                succedCount ++;
                            } else {
                                failedCount ++;
                            }
                        }
                    } catch (Exception e) {
                        log.error("批量操作失败了,id:{}", idTemp, e);
                        failedCount ++;
                    }
                }
            } else {
                /* 未选择类型,ids */
                info = "ids为空";
            }
        } else {
            /* 操作类型未选择 */
            info = "操作类型未选择";
        }

        String messInfo = "批量操作日志:提示信息:${info}, 总条数:${totalCount},成功条数:${succedCount},失败条数:${failedCount}";
        Map<String,String> paramsMap = new HashMap<>(1);
        paramsMap.put("info", info);
        paramsMap.put("totalCount", String.valueOf(totalCount));
        paramsMap.put("succedCount", String.valueOf(succedCount));
        paramsMap.put("failedCount", String.valueOf(failedCount));
        messInfo = this.regexUtil.replaceOperator(messInfo, paramsMap);

        paramsMap = new HashMap<>(1);
        paramsMap.put(ConstatFinalUtil.FINAL_CONFIG_INFO_SUCCESS_PARAM1, messInfo);
        /* 查询数据 */
        JSONObject resultJson = this.proccedResponseJson(ConstatFinalUtil.FINAL_OPER_SUCCESS.equalsIgnoreCase(info), paramsMap);
        log.info("==结果:{}==", resultJson);
        return resultJson.toJSONString();
    }

    /**
     * 周日程管理查询多条
     * @return
     */
    @RequestMapping("/scheduleList")
    public String scheduleList(AtUsersScheduleQuery paramQuery, Model model){
        log.info("==周日程管理列表==");
        /* 分页对象 */
        IPage<AtUsersSchedule> paramPage = null;
        try {
            paramPage = new Page<>(paramQuery.getCurrent(), paramQuery.getSize());
        } catch (Exception e) {
            paramPage = new Page<>(1, 20);
        }
        /* 时间处理 */
        if (StringUtils.isNotEmpty(paramQuery.getStDate())) {
            paramQuery.setPubTimeSt(this.dateUtil.strToDateTime(paramQuery.getStDate()));
        }
        if (StringUtils.isNotEmpty(paramQuery.getEdDate())) {
            paramQuery.setPubTimeEd(this.dateUtil.strToDateTime(paramQuery.getEdDate()));
        }
        paramQuery.addLike();
        /* 查询对象 */
        List<AtUsersSchedule> dataList = this.usersScheduleService.findList(paramPage, paramQuery);
        paramQuery.removeLike();
        /* 列表数据 */
        model.addAttribute(ConstatFinalUtil.FINAL_CODE_DATALIST, dataList);
        /* 分页数据 */
        model.addAttribute(ConstatFinalUtil.FINAL_CODE_PAGEINFOUTIL, paramPage);
        model.addAttribute(ConstatFinalUtil.FINAL_CODE_PARAMQUERY, paramQuery);
        model.addAttribute(ConstatFinalUtil.FINAL_CODE_ENUMSONE, new AtUsersSchedule());
        /* 查询数据 */
        return "back/users/scheduleList";
    }

    /**
     * 周日程管理打开更新页面
     * 更新和详情是同一个页面;
     * @return
     */
    @RequestMapping("/scheduleUpdate")
    public String scheduleUpdate(AtUsersScheduleQuery paramQuery, Model model){
        log.info("==周日程管理更新==");
        /* 根据id查询 */
        AtUsersSchedule one = this.usersScheduleService.findOne(paramQuery);
        model.addAttribute(ConstatFinalUtil.FINAL_CODE_ONE, one);

        if (BaseQuery.FINAL_OPER_UPDATE.equalsIgnoreCase(paramQuery.getOperType())) {
            /* 查询数据 */
            return "back/users/scheduleUpdate";
        }
        /* 查询数据 */
        return "back/users/scheduleInfo";
    }

    /**
     * 周日程管理更新提交操作
     * <pre>
     * 周日程管理表有10个字段,用户填写的只有5个字段;
     * 更新的时候只更新5个字段;剩下的5个字段不用更新
     * 千万不要把页面中传的参数SpringMVC会自动创建对象,这个对象不要直接更新数据库,很危险;
     * </pre>
     * @return
     */
    @RequestMapping("/scheduleUpdateSubmit")
    @ResponseBody
    public String scheduleUpdateSubmit(AtUsersScheduleQuery paramQuery, HttpSession session, Model model){
        log.info("==周日程管理更新提交==");
        AtRbacAdmins adminsSess = (AtRbacAdmins) session.getAttribute("adminsSess");
        AtUsersSchedule entity = paramQuery.getEntity();
        if (StringUtils.isNotEmpty(paramQuery.getPubTime())) {
            entity.setPubTime(this.dateUtil.strToDateTime(paramQuery.getPubTime()));
        }
        if (AtUsersScheduleEnum.STATUSNEW_SHTG.getCode().equalsIgnoreCase(entity.getStatus()) ||
                AtUsersScheduleEnum.STATUSNEW_SHBTG.getCode().equalsIgnoreCase(entity.getStatus())) {
            entity.setAuditId(adminsSess.getId());
            entity.setAuditTime(new Date());
        }
        boolean dbFlag = this.usersScheduleService.updateById(entity);
        JSONObject resultJson = this.proccedResponseJson(dbFlag);
        /* 返回json给客户端 */
        return resultJson.toJSONString();
    }

    /**
     * 周日程管理打开添加页面
     * @return
     */
    @RequestMapping("/scheduleBatch")
    @ResponseBody
    public String scheduleBatch(AtUsersScheduleQuery paramQuery, Model model){
        log.info("==周日程管理批量提交==");
        String operType = paramQuery.getOperType();
        String[] ids = paramQuery.getIds();
        String info = ConstatFinalUtil.FINAL_OPER_SUCCESS;
        int totalCount = 0;
        int succedCount = 0;
        int failedCount = 0;
        if (StringUtils.isNotEmpty(operType)) {
            if (Objects.nonNull(ids) && ids.length > 0) {
                totalCount = ids.length;
                for (String idTemp : ids) {
                    try {
                        AtUsersScheduleQuery paramQueryTemp = new AtUsersScheduleQuery();
                        AtUsersSchedule entity = paramQueryTemp.getEntity();
                        entity.setId(idTemp);
                        /* 根据id查询每一个 记录对象 */
                        AtUsersSchedule dataDbResult = this.usersScheduleService.findOne(paramQueryTemp);
                        if (dataDbResult != null) {
                            boolean dbFlag = false;
                            if (BasePojoEnum.OPERTYPE_DELETE.getCode().equalsIgnoreCase(operType)) {
                                /* 删除 */
                                dbFlag = this.usersScheduleService.removeById(idTemp);
                            } else if (BasePojoEnum.OPERTYPE_RESTORE.getCode().equalsIgnoreCase(operType)) {
                                /* 还原,为什么这里面要传这么多参数,一切的一切就是为了在xml中拼装sql语句 */
                                paramQueryTemp = new AtUsersScheduleQuery();
                                entity = paramQueryTemp.getEntity();
                                entity.setDelFlag(BasePojoEnum.DELFLAG_NO.getCode());
                                entity.setId(idTemp);
                                paramQueryTemp.setOperType(BasePojoEnum.OPERTYPE_RESTORE.getCode());
                                dbFlag = this.usersScheduleService.updateBatch(paramQueryTemp) > 0 ;
                            } else if (BasePojoEnum.OPERTYPE_EMPTY.getCode().equalsIgnoreCase(operType)) {
                                /* 清空 */
                                paramQueryTemp = new AtUsersScheduleQuery();
                                entity = paramQueryTemp.getEntity();
                                entity.setId(idTemp);
                                dbFlag = this.usersScheduleService.deleteBatch(paramQueryTemp) > 0 ;
                            } else if (BasePojoEnum.OPERTYPE_UPDATESTATUS.getCode().equalsIgnoreCase(operType)) {
                                /* 批量修改状态 */
                                dataDbResult.setStatus(paramQuery.getEntity().getStatus());
                                dbFlag = this.usersScheduleService.updateById(dataDbResult);
                            }
                            if (dbFlag) {
                                succedCount ++;
                            } else {
                                failedCount ++;
                            }
                        }
                    } catch (Exception e) {
                        log.error("批量操作失败了,id:{}", idTemp, e);
                        failedCount ++;
                    }
                }
            } else {
                /* 未选择类型,ids */
                info = "ids为空";
            }
        } else {
            /* 操作类型未选择 */
            info = "操作类型未选择";
        }

        String messInfo = "批量操作日志:提示信息:${info}, 总条数:${totalCount},成功条数:${succedCount},失败条数:${failedCount}";
        Map<String,String> paramsMap = new HashMap<>(1);
        paramsMap.put("info", info);
        paramsMap.put("totalCount", String.valueOf(totalCount));
        paramsMap.put("succedCount", String.valueOf(succedCount));
        paramsMap.put("failedCount", String.valueOf(failedCount));
        messInfo = this.regexUtil.replaceOperator(messInfo, paramsMap);

        paramsMap = new HashMap<>(1);
        paramsMap.put(ConstatFinalUtil.FINAL_CONFIG_INFO_SUCCESS_PARAM1, messInfo);
        /* 查询数据 */
        JSONObject resultJson = this.proccedResponseJson(ConstatFinalUtil.FINAL_OPER_SUCCESS.equalsIgnoreCase(info), paramsMap);
        log.info("==结果:{}==", resultJson);
        return resultJson.toJSONString();
    }

    /**
     * 考察行程查询多条
     * @return
     */
    @RequestMapping("/investigateList")
    public String investigateList(AtUsersInvestigateQuery paramQuery, Model model){
        log.info("==考察行程列表==");
        /* 分页对象 */
        IPage<AtUsersInvestigate> paramPage = null;
        try {
            paramPage = new Page<>(paramQuery.getCurrent(), paramQuery.getSize());
        } catch (Exception e) {
            paramPage = new Page<>(1, 20);
        }
        /* 时间处理 */
        if (StringUtils.isNotEmpty(paramQuery.getStDate())) {
            paramQuery.setPubTimeSt(this.dateUtil.strToDateTime(paramQuery.getStDate()));
        }
        if (StringUtils.isNotEmpty(paramQuery.getEdDate())) {
            paramQuery.setPubTimeEd(this.dateUtil.strToDateTime(paramQuery.getEdDate()));
        }
        paramQuery.addLike();
        /* 查询对象 */
        List<AtUsersInvestigate> dataList = this.usersInvestigateService.findList(paramPage, paramQuery);
        paramQuery.removeLike();
        /* 列表数据 */
        model.addAttribute(ConstatFinalUtil.FINAL_CODE_DATALIST, dataList);
        /* 分页数据 */
        model.addAttribute(ConstatFinalUtil.FINAL_CODE_PAGEINFOUTIL, paramPage);
        model.addAttribute(ConstatFinalUtil.FINAL_CODE_PARAMQUERY, paramQuery);
        model.addAttribute(ConstatFinalUtil.FINAL_CODE_ENUMSONE, new AtUsersInvestigate());
        /* 查询数据 */
        return "back/users/investigateList";
    }

    /**
     * 考察行程打开更新页面
     * 更新和详情是同一个页面;
     * @return
     */
    @RequestMapping("/investigateUpdate")
    public String investigateUpdate(AtUsersInvestigateQuery paramQuery, Model model){
        log.info("==考察行程更新==");
        /* 根据id查询 */
        AtUsersInvestigate one = this.usersInvestigateService.findOne(paramQuery);
        model.addAttribute(ConstatFinalUtil.FINAL_CODE_ONE, one);

        if (BaseQuery.FINAL_OPER_UPDATE.equalsIgnoreCase(paramQuery.getOperType())) {
            /* 查询数据 */
            return "back/users/investigateUpdate";
        }
        /* 查询数据 */
        return "back/users/investigateInfo";
    }

    /**
     * 考察行程更新提交操作
     * <pre>
     * 考察行程表有10个字段,用户填写的只有5个字段;
     * 更新的时候只更新5个字段;剩下的5个字段不用更新
     * 千万不要把页面中传的参数SpringMVC会自动创建对象,这个对象不要直接更新数据库,很危险;
     * </pre>
     * @return
     */
    @RequestMapping("/investigateUpdateSubmit")
    @ResponseBody
    public String investigateUpdateSubmit(AtUsersInvestigateQuery paramQuery, HttpSession session, Model model){
        log.info("==考察行程更新提交==");
        AtRbacAdmins adminsSess = (AtRbacAdmins) session.getAttribute("adminsSess");
        AtUsersInvestigate entity = paramQuery.getEntity();
        if (StringUtils.isNotEmpty(paramQuery.getPubTime())) {
            entity.setPubTime(this.dateUtil.strToDateTime(paramQuery.getPubTime()));
        }
        if (AtUsersInvestigateEnum.STATUSNEW_SHTG.getCode().equalsIgnoreCase(entity.getStatus()) ||
                AtUsersInvestigateEnum.STATUSNEW_SHBTG.getCode().equalsIgnoreCase(entity.getStatus())) {
            entity.setAuditId(adminsSess.getId());
            entity.setAuditTime(new Date());
        }
        boolean dbFlag = this.usersInvestigateService.updateById(entity);
        JSONObject resultJson = this.proccedResponseJson(dbFlag);
        /* 返回json给客户端 */
        return resultJson.toJSONString();
    }

    /**
     * 考察行程打开添加页面
     * @return
     */
    @RequestMapping("/investigateBatch")
    @ResponseBody
    public String investigateBatch(AtUsersInvestigateQuery paramQuery, Model model){
        log.info("==考察行程批量提交==");
        String operType = paramQuery.getOperType();
        String[] ids = paramQuery.getIds();
        String info = ConstatFinalUtil.FINAL_OPER_SUCCESS;
        int totalCount = 0;
        int succedCount = 0;
        int failedCount = 0;
        if (StringUtils.isNotEmpty(operType)) {
            if (Objects.nonNull(ids) && ids.length > 0) {
                totalCount = ids.length;
                for (String idTemp : ids) {
                    try {
                        AtUsersInvestigateQuery paramQueryTemp = new AtUsersInvestigateQuery();
                        AtUsersInvestigate entity = paramQueryTemp.getEntity();
                        entity.setId(idTemp);
                        /* 根据id查询每一个 记录对象 */
                        AtUsersInvestigate dataDbResult = this.usersInvestigateService.findOne(paramQueryTemp);
                        if (dataDbResult != null) {
                            boolean dbFlag = false;
                            if (BasePojoEnum.OPERTYPE_DELETE.getCode().equalsIgnoreCase(operType)) {
                                /* 删除 */
                                dbFlag = this.usersInvestigateService.removeById(idTemp);
                            } else if (BasePojoEnum.OPERTYPE_RESTORE.getCode().equalsIgnoreCase(operType)) {
                                /* 还原,为什么这里面要传这么多参数,一切的一切就是为了在xml中拼装sql语句 */
                                paramQueryTemp = new AtUsersInvestigateQuery();
                                entity = paramQueryTemp.getEntity();
                                entity.setDelFlag(BasePojoEnum.DELFLAG_NO.getCode());
                                entity.setId(idTemp);
                                paramQueryTemp.setOperType(BasePojoEnum.OPERTYPE_RESTORE.getCode());
                                dbFlag = this.usersInvestigateService.updateBatch(paramQueryTemp) > 0 ;
                            } else if (BasePojoEnum.OPERTYPE_EMPTY.getCode().equalsIgnoreCase(operType)) {
                                /* 清空 */
                                paramQueryTemp = new AtUsersInvestigateQuery();
                                entity = paramQueryTemp.getEntity();
                                entity.setId(idTemp);
                                dbFlag = this.usersInvestigateService.deleteBatch(paramQueryTemp) > 0 ;
                            } else if (BasePojoEnum.OPERTYPE_UPDATESTATUS.getCode().equalsIgnoreCase(operType)) {
                                /* 批量修改状态 */
                                dataDbResult.setStatus(paramQuery.getEntity().getStatus());
                                dbFlag = this.usersInvestigateService.updateById(dataDbResult);
                            }
                            if (dbFlag) {
                                succedCount ++;
                            } else {
                                failedCount ++;
                            }
                        }
                    } catch (Exception e) {
                        log.error("批量操作失败了,id:{}", idTemp, e);
                        failedCount ++;
                    }
                }
            } else {
                /* 未选择类型,ids */
                info = "ids为空";
            }
        } else {
            /* 操作类型未选择 */
            info = "操作类型未选择";
        }

        String messInfo = "批量操作日志:提示信息:${info}, 总条数:${totalCount},成功条数:${succedCount},失败条数:${failedCount}";
        Map<String,String> paramsMap = new HashMap<>(1);
        paramsMap.put("info", info);
        paramsMap.put("totalCount", String.valueOf(totalCount));
        paramsMap.put("succedCount", String.valueOf(succedCount));
        paramsMap.put("failedCount", String.valueOf(failedCount));
        messInfo = this.regexUtil.replaceOperator(messInfo, paramsMap);

        paramsMap = new HashMap<>(1);
        paramsMap.put(ConstatFinalUtil.FINAL_CONFIG_INFO_SUCCESS_PARAM1, messInfo);
        /* 查询数据 */
        JSONObject resultJson = this.proccedResponseJson(ConstatFinalUtil.FINAL_OPER_SUCCESS.equalsIgnoreCase(info), paramsMap);
        log.info("==结果:{}==", resultJson);
        return resultJson.toJSONString();
    }

    /**
     * 外事登记查询多条
     * @return
     */
    @RequestMapping("/activityList")
    public String activityList(AtUsersActivityQuery paramQuery, Model model){
        log.info("==外事登记列表==");
        /* 分页对象 */
        IPage<AtUsersActivity> paramPage = null;
        try {
            paramPage = new Page<>(paramQuery.getCurrent(), paramQuery.getSize());
        } catch (Exception e) {
            paramPage = new Page<>(1, 20);
        }
        /* 时间处理 */
        if (StringUtils.isNotEmpty(paramQuery.getStDate())) {
            paramQuery.setPubTimeSt(this.dateUtil.strToDateTime(paramQuery.getStDate()));
        }
        if (StringUtils.isNotEmpty(paramQuery.getEdDate())) {
            paramQuery.setPubTimeEd(this.dateUtil.strToDateTime(paramQuery.getEdDate()));
        }
        paramQuery.addLike();
        /* 查询对象 */
        List<AtUsersActivity> dataList = this.usersActivityService.findList(paramPage, paramQuery);
        paramQuery.removeLike();
        /* 列表数据 */
        model.addAttribute(ConstatFinalUtil.FINAL_CODE_DATALIST, dataList);
        /* 分页数据 */
        model.addAttribute(ConstatFinalUtil.FINAL_CODE_PAGEINFOUTIL, paramPage);
        model.addAttribute(ConstatFinalUtil.FINAL_CODE_PARAMQUERY, paramQuery);
        model.addAttribute(ConstatFinalUtil.FINAL_CODE_ENUMSONE, new AtUsersActivity());
        /* 查询数据 */
        return "back/users/activityList";
    }

    /**
     * 外事登记打开更新页面
     * 更新和详情是同一个页面;
     * @return
     */
    @RequestMapping("/activityUpdate")
    public String activityUpdate(AtUsersActivityQuery paramQuery, Model model){
        log.info("==外事登记更新==");
        /* 根据id查询 */
        AtUsersActivity one = this.usersActivityService.findOne(paramQuery);
        model.addAttribute(ConstatFinalUtil.FINAL_CODE_ONE, one);

        if (BaseQuery.FINAL_OPER_UPDATE.equalsIgnoreCase(paramQuery.getOperType())) {
            /* 查询数据 */
            return "back/users/activityUpdate";
        }
        /* 查询数据 */
        return "back/users/activityInfo";
    }

    /**
     * 外事登记更新提交操作
     * <pre>
     * 外事登记表有10个字段,用户填写的只有5个字段;
     * 更新的时候只更新5个字段;剩下的5个字段不用更新
     * 千万不要把页面中传的参数SpringMVC会自动创建对象,这个对象不要直接更新数据库,很危险;
     * </pre>
     * @return
     */
    @RequestMapping("/activityUpdateSubmit")
    @ResponseBody
    public String activityUpdateSubmit(AtUsersActivityQuery paramQuery, HttpSession session, Model model){
        log.info("==外事登记更新提交==");
        AtRbacAdmins adminsSess = (AtRbacAdmins) session.getAttribute("adminsSess");
        AtUsersActivity entity = paramQuery.getEntity();
        if (StringUtils.isNotEmpty(paramQuery.getPubTime())) {
            entity.setPubTime(this.dateUtil.strToDateTime(paramQuery.getPubTime()));
        }
        if (AtUsersActivityEnum.STATUSNEW_SHTG.getCode().equalsIgnoreCase(entity.getStatus()) ||
                AtUsersActivityEnum.STATUSNEW_SHBTG.getCode().equalsIgnoreCase(entity.getStatus())) {
            entity.setAuditId(adminsSess.getId());
            entity.setAuditTime(new Date());
        }
        boolean dbFlag = this.usersActivityService.updateById(entity);
        JSONObject resultJson = this.proccedResponseJson(dbFlag);
        /* 返回json给客户端 */
        return resultJson.toJSONString();
    }

    /**
     * 外事登记打开添加页面
     * @return
     */
    @RequestMapping("/activityBatch")
    @ResponseBody
    public String activityBatch(AtUsersActivityQuery paramQuery, Model model){
        log.info("==外事登记批量提交==");
        String operType = paramQuery.getOperType();
        String[] ids = paramQuery.getIds();
        String info = ConstatFinalUtil.FINAL_OPER_SUCCESS;
        int totalCount = 0;
        int succedCount = 0;
        int failedCount = 0;
        if (StringUtils.isNotEmpty(operType)) {
            if (Objects.nonNull(ids) && ids.length > 0) {
                totalCount = ids.length;
                for (String idTemp : ids) {
                    try {
                        AtUsersActivityQuery paramQueryTemp = new AtUsersActivityQuery();
                        AtUsersActivity entity = paramQueryTemp.getEntity();
                        entity.setId(idTemp);
                        /* 根据id查询每一个 记录对象 */
                        AtUsersActivity dataDbResult = this.usersActivityService.findOne(paramQueryTemp);
                        if (dataDbResult != null) {
                            boolean dbFlag = false;
                            if (BasePojoEnum.OPERTYPE_DELETE.getCode().equalsIgnoreCase(operType)) {
                                /* 删除 */
                                dbFlag = this.usersActivityService.removeById(idTemp);
                            } else if (BasePojoEnum.OPERTYPE_RESTORE.getCode().equalsIgnoreCase(operType)) {
                                /* 还原,为什么这里面要传这么多参数,一切的一切就是为了在xml中拼装sql语句 */
                                paramQueryTemp = new AtUsersActivityQuery();
                                entity = paramQueryTemp.getEntity();
                                entity.setDelFlag(BasePojoEnum.DELFLAG_NO.getCode());
                                entity.setId(idTemp);
                                paramQueryTemp.setOperType(BasePojoEnum.OPERTYPE_RESTORE.getCode());
                                dbFlag = this.usersActivityService.updateBatch(paramQueryTemp) > 0 ;
                            } else if (BasePojoEnum.OPERTYPE_EMPTY.getCode().equalsIgnoreCase(operType)) {
                                /* 清空 */
                                paramQueryTemp = new AtUsersActivityQuery();
                                entity = paramQueryTemp.getEntity();
                                entity.setId(idTemp);
                                dbFlag = this.usersActivityService.deleteBatch(paramQueryTemp) > 0 ;
                            } else if (BasePojoEnum.OPERTYPE_UPDATESTATUS.getCode().equalsIgnoreCase(operType)) {
                                /* 批量修改状态 */
                                dataDbResult.setStatus(paramQuery.getEntity().getStatus());
                                dbFlag = this.usersActivityService.updateById(dataDbResult);
                            }
                            if (dbFlag) {
                                succedCount ++;
                            } else {
                                failedCount ++;
                            }
                        }
                    } catch (Exception e) {
                        log.error("批量操作失败了,id:{}", idTemp, e);
                        failedCount ++;
                    }
                }
            } else {
                /* 未选择类型,ids */
                info = "ids为空";
            }
        } else {
            /* 操作类型未选择 */
            info = "操作类型未选择";
        }

        String messInfo = "批量操作日志:提示信息:${info}, 总条数:${totalCount},成功条数:${succedCount},失败条数:${failedCount}";
        Map<String,String> paramsMap = new HashMap<>(1);
        paramsMap.put("info", info);
        paramsMap.put("totalCount", String.valueOf(totalCount));
        paramsMap.put("succedCount", String.valueOf(succedCount));
        paramsMap.put("failedCount", String.valueOf(failedCount));
        messInfo = this.regexUtil.replaceOperator(messInfo, paramsMap);

        paramsMap = new HashMap<>(1);
        paramsMap.put(ConstatFinalUtil.FINAL_CONFIG_INFO_SUCCESS_PARAM1, messInfo);
        /* 查询数据 */
        JSONObject resultJson = this.proccedResponseJson(ConstatFinalUtil.FINAL_OPER_SUCCESS.equalsIgnoreCase(info), paramsMap);
        log.info("==结果:{}==", resultJson);
        return resultJson.toJSONString();
    }

    /**
     * 考察报告查询多条
     * @return
     */
    @RequestMapping("/reportList")
    public String reportList(AtUsersReportQuery paramQuery, Model model){
        log.info("==考察报告列表==");
        /* 分页对象 */
        IPage<AtUsersReport> paramPage = null;
        try {
            paramPage = new Page<>(paramQuery.getCurrent(), paramQuery.getSize());
        } catch (Exception e) {
            paramPage = new Page<>(1, 20);
        }
        /* 时间处理 */
        if (StringUtils.isNotEmpty(paramQuery.getStDate())) {
            paramQuery.setPubTimeSt(this.dateUtil.strToDateTime(paramQuery.getStDate()));
        }
        if (StringUtils.isNotEmpty(paramQuery.getEdDate())) {
            paramQuery.setPubTimeEd(this.dateUtil.strToDateTime(paramQuery.getEdDate()));
        }
        paramQuery.addLike();
        /* 查询对象 */
        List<AtUsersReport> dataList = this.usersReportService.findList(paramPage, paramQuery);
        paramQuery.removeLike();
        /* 列表数据 */
        model.addAttribute(ConstatFinalUtil.FINAL_CODE_DATALIST, dataList);
        /* 分页数据 */
        model.addAttribute(ConstatFinalUtil.FINAL_CODE_PAGEINFOUTIL, paramPage);
        model.addAttribute(ConstatFinalUtil.FINAL_CODE_PARAMQUERY, paramQuery);
        model.addAttribute(ConstatFinalUtil.FINAL_CODE_ENUMSONE, new AtUsersReport());
        /* 查询数据 */
        return "back/users/reportList";
    }

    /**
     * 考察报告打开更新页面
     * 更新和详情是同一个页面;
     * @return
     */
    @RequestMapping("/reportUpdate")
    public String reportUpdate(AtUsersReportQuery paramQuery, Model model){
        log.info("==考察报告更新==");
        /* 根据id查询 */
        AtUsersReport one = this.usersReportService.findOne(paramQuery);
        model.addAttribute(ConstatFinalUtil.FINAL_CODE_ONE, one);

        if (BaseQuery.FINAL_OPER_UPDATE.equalsIgnoreCase(paramQuery.getOperType())) {
            /* 查询数据 */
            return "back/users/reportUpdate";
        }
        /* 查询数据 */
        return "back/users/reportInfo";
    }

    /**
     * 考察报告更新提交操作
     * <pre>
     * 考察报告表有10个字段,用户填写的只有5个字段;
     * 更新的时候只更新5个字段;剩下的5个字段不用更新
     * 千万不要把页面中传的参数SpringMVC会自动创建对象,这个对象不要直接更新数据库,很危险;
     * </pre>
     * @return
     */
    @RequestMapping("/reportUpdateSubmit")
    @ResponseBody
    public String reportUpdateSubmit(AtUsersReportQuery paramQuery, HttpSession session, Model model){
        log.info("==考察报告更新提交==");
        AtRbacAdmins adminsSess = (AtRbacAdmins) session.getAttribute("adminsSess");
        AtUsersReport entity = paramQuery.getEntity();
        if (StringUtils.isNotEmpty(paramQuery.getPubTime())) {
            entity.setPubTime(this.dateUtil.strToDateTime(paramQuery.getPubTime()));
        }
        boolean dbFlag = this.usersReportService.updateById(entity);
        JSONObject resultJson = this.proccedResponseJson(dbFlag);
        /* 返回json给客户端 */
        return resultJson.toJSONString();
    }

    /**
     * 考察报告打开添加页面
     * @return
     */
    @RequestMapping("/reportBatch")
    @ResponseBody
    public String reportBatch(AtUsersReportQuery paramQuery, Model model){
        log.info("==考察报告批量提交==");
        String operType = paramQuery.getOperType();
        String[] ids = paramQuery.getIds();
        String info = ConstatFinalUtil.FINAL_OPER_SUCCESS;
        int totalCount = 0;
        int succedCount = 0;
        int failedCount = 0;
        if (StringUtils.isNotEmpty(operType)) {
            if (Objects.nonNull(ids) && ids.length > 0) {
                totalCount = ids.length;
                for (String idTemp : ids) {
                    try {
                        AtUsersReportQuery paramQueryTemp = new AtUsersReportQuery();
                        AtUsersReport entity = paramQueryTemp.getEntity();
                        entity.setId(idTemp);
                        /* 根据id查询每一个 记录对象 */
                        AtUsersReport dataDbResult = this.usersReportService.findOne(paramQueryTemp);
                        if (dataDbResult != null) {
                            boolean dbFlag = false;
                            if (BasePojoEnum.OPERTYPE_DELETE.getCode().equalsIgnoreCase(operType)) {
                                /* 删除 */
                                dbFlag = this.usersReportService.removeById(idTemp);
                            } else if (BasePojoEnum.OPERTYPE_RESTORE.getCode().equalsIgnoreCase(operType)) {
                                /* 还原,为什么这里面要传这么多参数,一切的一切就是为了在xml中拼装sql语句 */
                                paramQueryTemp = new AtUsersReportQuery();
                                entity = paramQueryTemp.getEntity();
                                entity.setDelFlag(BasePojoEnum.DELFLAG_NO.getCode());
                                entity.setId(idTemp);
                                paramQueryTemp.setOperType(BasePojoEnum.OPERTYPE_RESTORE.getCode());
                                dbFlag = this.usersReportService.updateBatch(paramQueryTemp) > 0 ;
                            } else if (BasePojoEnum.OPERTYPE_EMPTY.getCode().equalsIgnoreCase(operType)) {
                                /* 清空 */
                                paramQueryTemp = new AtUsersReportQuery();
                                entity = paramQueryTemp.getEntity();
                                entity.setId(idTemp);
                                dbFlag = this.usersReportService.deleteBatch(paramQueryTemp) > 0 ;
                            } else if (BasePojoEnum.OPERTYPE_UPDATESTATUS.getCode().equalsIgnoreCase(operType)) {
                                /* 批量修改状态 */
                                dataDbResult.setStatus(paramQuery.getEntity().getStatus());
                                dbFlag = this.usersReportService.updateById(dataDbResult);
                            }
                            if (dbFlag) {
                                succedCount ++;
                            } else {
                                failedCount ++;
                            }
                        }
                    } catch (Exception e) {
                        log.error("批量操作失败了,id:{}", idTemp, e);
                        failedCount ++;
                    }
                }
            } else {
                /* 未选择类型,ids */
                info = "ids为空";
            }
        } else {
            /* 操作类型未选择 */
            info = "操作类型未选择";
        }

        String messInfo = "批量操作日志:提示信息:${info}, 总条数:${totalCount},成功条数:${succedCount},失败条数:${failedCount}";
        Map<String,String> paramsMap = new HashMap<>(1);
        paramsMap.put("info", info);
        paramsMap.put("totalCount", String.valueOf(totalCount));
        paramsMap.put("succedCount", String.valueOf(succedCount));
        paramsMap.put("failedCount", String.valueOf(failedCount));
        messInfo = this.regexUtil.replaceOperator(messInfo, paramsMap);

        paramsMap = new HashMap<>(1);
        paramsMap.put(ConstatFinalUtil.FINAL_CONFIG_INFO_SUCCESS_PARAM1, messInfo);
        /* 查询数据 */
        JSONObject resultJson = this.proccedResponseJson(ConstatFinalUtil.FINAL_OPER_SUCCESS.equalsIgnoreCase(info), paramsMap);
        log.info("==结果:{}==", resultJson);
        return resultJson.toJSONString();
    }
}